package com.deyuanyun.pic.ctrl.controller.vo.exinsp;

import com.deyuanyun.pic.common.util.NumberUtil;
import com.deyuanyun.pic.common.util.format.DateFormat;
import com.deyuanyun.pic.ctrl.domain.ExinspCipsDcvg;
import com.deyuanyun.pic.ctrl.enumeration.CathodicProtectionEvaluationEnum;
import com.deyuanyun.pic.ctrl.enumeration.CycleEnum;
import com.deyuanyun.pic.pipe.controller.vo.BaseVOUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.math.BigDecimal;

/**
 * CIPS+DCVG检测记录表
 */
public class ExinspCipsDcvgVO extends ExinspBaseVO<ExinspCipsDcvg> {

    // 管道名称
    private String pipeLineName;
    // 测试桩编号
    private String testStationNum;
    // 监测点编号
    private String detectionPointNumber;
    // 防腐层漏损点编号PIC_CRTL_EXINSP_OCLPOINT
    private String oclpointId;
    // 绝对距离（m）
    private BigDecimal mileage;
    // 附近测试桩
    private String nagm;
    // 附近测试桩距离
    private BigDecimal nagmMileage;
    // 通断周期（通电时间/断电时间） 800ms/200ms
    private String cycle;
    // CIPS_通电电位（mV）
    public Integer cipsOnPotential;
    // CIPS_断电电位（mV）
    public Integer cipsOffPotential;
    // DCVG_通电电位梯度（mV/m）
    public Integer dcvgOn;
    // DCVG_断电电位梯度（mV/m）
    public Integer dcvgOff;
    // DCVG_IR%
    private BigDecimal dcvgIr;
    // 阴保有效性评价（有效、欠、过）
    private String cathodicProtectionEvaluation;
    // 检测日期
    private String testingDate;
    // 检测单位
    private String testingCompany;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getTestStationNum() {
        return testStationNum;
    }

    public void setTestStationNum(String testStationNum) {
        this.testStationNum = testStationNum;
    }

    public String getDetectionPointNumber() {
        return detectionPointNumber.equals("null")?"":detectionPointNumber;
    }

    public void setDetectionPointNumber(String detectionPointNumber) {
        this.detectionPointNumber = detectionPointNumber;
    }

    public String getOclpointId() {
        return oclpointId;
    }

    public void setOclpointId(String oclpointId) {
        this.oclpointId = oclpointId;
    }

    public BigDecimal getMileage() {
        return mileage;
    }

    public void setMileage(BigDecimal mileage) {
        this.mileage = mileage;
    }

    public String getNagm() {
        return nagm;
    }

    public void setNagm(String nagm) {
        this.nagm = nagm;
    }

    public BigDecimal getNagmMileage() {
        return nagmMileage;
    }

    public void setNagmMileage(BigDecimal nagmMileage) {
        this.nagmMileage = nagmMileage;
    }

    public String getCycle() {
        return cycle;
    }

    public void setCycle(String cycle) {
        this.cycle = cycle;
    }

    public Integer getCipsOnPotential() {
        return cipsOnPotential;
    }

    public void setCipsOnPotential(Integer cipsOnPotential) {
        this.cipsOnPotential = cipsOnPotential;
    }

    public Integer getCipsOffPotential() {
        return cipsOffPotential;
    }

    public void setCipsOffPotential(Integer cipsOffPotential) {
        this.cipsOffPotential = cipsOffPotential;
    }

    public Integer getDcvgOn() {
        return dcvgOn;
    }

    public void setDcvgOn(Integer dcvgOn) {
        this.dcvgOn = dcvgOn;
    }

    public Integer getDcvgOff() {
        return dcvgOff;
    }

    public void setDcvgOff(Integer dcvgOff) {
        this.dcvgOff = dcvgOff;
    }

    public BigDecimal getDcvgIr() {
        return dcvgIr;
    }

    public void setDcvgIr(BigDecimal dcvgIr) {
        this.dcvgIr = dcvgIr;
    }

    public String getCathodicProtectionEvaluation() {
        return cathodicProtectionEvaluation;
    }

    public void setCathodicProtectionEvaluation(String cathodicProtectionEvaluation) {
        this.cathodicProtectionEvaluation = cathodicProtectionEvaluation;
    }

    public String getTestingDate() {
        return testingDate;
    }

    public void setTestingDate(String testingDate) {
        this.testingDate = testingDate;
    }

    public String getTestingCompany() {
        return testingCompany;
    }

    public void setTestingCompany(String testingCompany) {
        this.testingCompany = testingCompany;
    }

    public void fromDomain(ExinspCipsDcvg domain) {

        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 测试桩编号
        this.testStationNum = domain.getTestStationId();
        // 监测点编号
        this.detectionPointNumber = String.valueOf(domain.getDetectionPointNumber());
        // 防腐层漏损点编号PIC_CRTL_EXINSP_OCLPOINT
        this.oclpointId = domain.getOclpointId();
        // 绝对距离（m）
        this.mileage = NumberUtil.toMeter(domain.getMileage());
        // 附近测试桩
        this.nagm = domain.getNagm();
        // 附近测试桩距离
        this.nagmMileage = NumberUtil.toMeter(domain.getNagmMileage());
        // 通断周期（通电时间/断电时间） 800ms/200ms
        this.cycle =  CycleEnum.getLabelBycode(domain.getCycle());
        // CIPS_通电电位（mV）
        this.cipsOnPotential = domain.getCipsOnPotential();
        // CIPS_断电电位（mV）
        this.cipsOffPotential = domain.getCipsOffPotential();
        // DCVG_通电电位梯度（mV/m）
        this.dcvgOn = domain.getDcvgOn();
        // DCVG_断电电位梯度（mV/m）
        this.dcvgOff = domain.getDcvgOff();
        // DCVG_IR%
        this.dcvgIr = domain.getDcvgIr();
        // 阴保有效性评价（有效、欠、过）
        this.cathodicProtectionEvaluation = CathodicProtectionEvaluationEnum.getLabel(domain.getCathodicProtectionEvaluation());
        // 检测日期
        this.testingDate = DateFormat.format(domain.getTestingDate());
        // 检测单位
        this.testingCompany = domain.getTestingCompany();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordTime(), domain.getRemarks());
    }

    public Page<ExinspCipsDcvgVO> fromDomainList(Page<ExinspCipsDcvg> domainList) {

        Page<ExinspCipsDcvgVO> list = new Page<ExinspCipsDcvgVO>();
        for (ExinspCipsDcvg exinspCipsDcvg : domainList) {
            ExinspCipsDcvgVO exinspCipsDcvgVO = new ExinspCipsDcvgVO();
            exinspCipsDcvgVO.fromDomain(exinspCipsDcvg);
            list.add(exinspCipsDcvgVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}